package com.sky.service.impl;

import com.github.pagehelper.PageHelper;
import com.sky.dto.OrdersCancelDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import com.sky.exception.OrderBusinessException;
import com.sky.mapper.OrderAdminMapper;
import com.sky.service.OrderAdminService;
import com.sky.vo.OrderVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OrderAdminServiceImpl implements OrderAdminService {
    @Autowired
    OrderAdminMapper orderAdminMapper;

    /**
     * 取消订单
     * @param ordersCancelDTO
     */
    @Override
    public void cancel(OrdersCancelDTO ordersCancelDTO) {
        Orders orders = orderAdminMapper.findById(ordersCancelDTO);
        if(orders==null){
            throw new OrderBusinessException("订单不存在");
        }
        if(ordersCancelDTO.getCancelReason()==null){
            throw new OrderBusinessException("订单取消原因不能为空");
        }
        BeanUtils.copyProperties(ordersCancelDTO,orders);
        orderAdminMapper.update(orders);

    }
}
